package com.java.computeronline.controller;

import java.util.List;

import com.java.computeronline.model.blo.SupplierBLO;
import com.java.computeronline.model.entity.Supplier;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class SupplierAction extends ActionSupport{
	private SupplierBLO supplierBLO;
	private List<Supplier> supplierList;
	private Supplier supplier;
	private Long id;
	
	public SupplierAction(){
		supplierBLO = new SupplierBLO();
	}
	
	public String execute(){
		supplierList = supplierBLO.list();
		return SUCCESS;
	}

	public String add(){
		try{
			Supplier supplier = getSupplier();
			supplierBLO.add(supplier);
		}catch(Exception ex){
			
		}
		return SUCCESS;
	}
	
	public String delete(){
		supplierBLO.delete(getId());
		return SUCCESS;
	}
	
	public String edit(){
		try{
			Supplier supplier = getSupplier();
			supplierBLO.update(supplier);
		}catch(Exception ex){
		}
		return SUCCESS;
	}
	
	public List<Supplier> getSupplierList() {
		return supplierList;
	}

	public void setSupplierList(List<Supplier> supplierList) {
		this.supplierList = supplierList;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	
}
